YNQ  YNQ-1.6.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups

Macros

#define SY_SEMAPHORE_AVAILABLE
 
#define SYSemaphore   sem_t
 
#define sySemaphoreDelete(_s)   sem_destroy(&_s)
 
#define sySemaphoreTake(_s)   sem_wait(&_s)
 
#define sySemaphoreGive(_s)   sem_post(&_s)
 

Functions

NQ_STATUS sySemaphoreCreate (SYSemaphore *semId, NQ_UINT count)
 
void sySemaphoreResetCounter (SYSemaphore *pSemID)
 
NQ_INT sySemaphoreTimedTake (SYSemaphore *sem, NQ_INT timeout)
 

Detailed Description

Semaphores

1) We use mutex semaphores or simulate their behavior if the OS does not support pure mutex semaphores. 2) We use binary semaphores

Macro Definition Documentation

#define SY_SEMAPHORE_AVAILABLE

Enable this define when semaphores are supported on system

#define SYSemaphore   sem_t

Counting semaphore

#define sySemaphoreDelete (   _s)    sem_destroy(&_s)
#define sySemaphoreTake (   _s)    sem_wait(&_s)
#define sySemaphoreGive (   _s)    sem_post(&_s)

Function Documentation

NQ_STATUS sySemaphoreCreate ( SYSemaphore semId,
NQ_UINT  count 
)

Create semaphore

Parameters
semIdPointer to the semaphore id
countNumber of resources
Returns
NQ_SUCCESS when semaphore was created or NQ_FAIL on error
void sySemaphoreResetCounter ( SYSemaphore pSemID)

Reset semaphore counter

Parameters
pSemIDPointer to the semaphore id
NQ_INT sySemaphoreTimedTake ( SYSemaphore sem,
NQ_INT  timeout 
)

Lock a resource protected by a binary semaphore

Parameters
semBinary semaphore
timeoutTimeout in seconds to wait for lock
Returns
NQ_SUCCESS when the resource was locked or NQ_FAIL on error